import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

export const albumApi = createApi({
  reducerPath: "albumApi",
  baseQuery: fetchBaseQuery({
    baseUrl: "http://jsonplaceholder.typicode.com/albums",
  }),
  endpoints: (builder) => ({
    getAlbums: builder.query({
      query: (id) => `?userId=${id}`,
    }),

    getPhotos: builder.query({
        query: (albumId) => `/${albumId}/photos`
    })
  }),
});

export const { useLazyGetAlbumsQuery, useLazyGetPhotosQuery } = albumApi;
